package beans;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;

public class Arquivo implements Comparable<Arquivo>{
	private BasicFileAttributes atributos;
	private File f;
	
	public Arquivo(File f) {
		this.f = f;
	
		try {
			this.atributos = Files.readAttributes(f.toPath(), BasicFileAttributes.class);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public BasicFileAttributes getAtributos(){
		return this.atributos;
	}
	
	public FileTime getTempoCriacao(){
		return this.atributos.creationTime();
	}
	
	public File getFile(){
		return f;
	}
	
	public void setFile(File f){
		this.f = f;
	}
	
	@Override
	public int compareTo(Arquivo o) {
		FileTime esteTempo = this.getTempoCriacao();
		return esteTempo.compareTo(o.getTempoCriacao());
	}
	
	@Override
	public String toString() {
		return f.getName();
	}
}
